{extend name=".././view/list.html" /}
{block name="jsset"}
{/block}
{block name="nav"}
<span class="layui-breadcrumb">
	<a href="">系统管理</a>
	<a href="">教务管理</a>
	<a><cite>任务分工</cite></a>
</span>
{/block}
{block name="search"}
<div class="layui-form-item" style="margin-bottom: 0;">
	<label for="searchval" class="layui-form-label">
		关键字
	</label>
	<div class="layui-input-block">
		<input type="text" id="searchval" name="searchval" autocomplete="off" class="layui-input"
			placeholder="输入关键字并回车">
	</div>
</div>
<div class="layui-form-item">
	<label for="xueqi_id" class="layui-form-label">学期</label>
	<div class="layui-input-block">
		<select name="xueqi_id" id="xueqi_id">
		</select>
	</div>
</div>
<div class="layui-form-item">
	<label for="subject_id" class="layui-form-label">学科</label>
	<div class="layui-input-block">
		<select name="subject_id" id="subject_id" lay-filter="src">
		</select>
	</div>
</div>
<div class="layui-form-item">
	<label for="ruxuenian" class="layui-form-label">年级</label>
	<div class="layui-input-block">
		<select id="ruxuenian" name="ruxuenian">
		</select>
	</div>
</div>
<div class="layui-form-item" style="text-align: right;">
	<button class="layui-btn" lay-filter="searchSubmit" lay-submit="">搜索</button>
</div>
{/block}
{block name="table"}
<table id="tabledemo" lay-filter="mytable" lay-size="sm"></table>
{/block}
{block name="myjs"}
<!-- 表格上面按钮模板 -->
<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-danger" lay-event="dels">
			<i class="iconfont">&#xe69d;</i> 批量删除
		</button>
		<button class="layui-btn" lay-event="add">
			<i class="iconfont">&#xe6b9;</i> 添加
		</button>
		<button class="layui-btn" lay-event="copy">
			<i class="iconfont">&#xe6b9;</i> 复制分工
		</button>
	</div>
</script>
<!-- 记录操作按钮模板 -->
<script type="text/html" id="barDemo">
	<!-- <a class="layui-btn-xs" lay-event="edit" title="编辑"><i class="layui-icon">&#xe642;</i></a> -->
<a class="layui-btn-xs" lay-event="del" title="删除"><i class="layui-icon">&#xe640;</i></a>
</script>
<!-- 状态按钮 -->
<script type="text/html" id="kaoshi">
	<input type="checkbox" myurl="{$list.kaoshi ? $list.kaoshi : url('kaoshi')}" {{d.kaoshi == 1 ? "checked" :""}} id="{{d.id}}" lay-skin="switch" lay-filter="kaoshi" lay-text="参加|不参加">
</script>
<!-- 表格操作 -->
<script>
	// 提交搜索条件后重载表格
	layui.use(['table', 'mytable', 'form', 'laydate', 'createInput'], function () {
		var table = layui.table,
			form = layui.form,
			mytable = layui.mytable
		cInput = layui.createInput;

		cInput.subjectSelect('subject_id', "", "", true);
		cInput.nanjiSelect('ruxuenian');
		cInput.xueqiSelect('xueqi_id', "", true);

		// 设置列
		options.cols = [
			[ //表头
				{ type: 'checkbox', fixed: 'left' },
				{
					field: 'teacher_id', title: '姓名', sort: true, minWidth: 100, templet: function (d) {
						var str = '';
						if (d.fgTeacher) {
							str = d.fgTeacher.xingming;
						}
						return str;
					}
				},
				{
					field: 'banji_id', title: '班级', sort: true, minWidth: 100, templet: function (d) {
						var str = '';
						if (d.fgBanji) {
							str = d.fgBanji.banjiTitle;
						}
						return str;
					}
				},
				{
					field: 'subject_id', title: '学科', minWidth: 100, sort: true, templet: function (d) {
						var str = '';
						if (d.fgSubject) {
							str = d.fgSubject.title;
						}
						return str;
					}
				},
				{
					field: 'xueqi_id', title: '学期', sort: true, minWidth: 150, templet: function (d) {
						var str = '';
						if (d.fgXueqi) {
							str = d.fgXueqi.title;
						}
						return str;
					}
				},
				{ field: 'bfdate', title: '接任时间', sort: true },
				{ field: 'id', title: '操作', toolbar: '#barDemo', minWidth: 140 }
			]
		];

		// 获取筛选条件并加载表格
		options.where = form.val("search");
		userTable = table.render(options); //获取数据并渲染

		//表头工具栏事件
		table.on('toolbar(mytable)', function (obj) {
			switch (obj.event) {
				case 'dels':
					var checkStatus = table.checkStatus('mytable'); //idmytable 即为基础参数 id 对应的值
					mytable.delAll(checkStatus, '/teach/fengong/delete', 'mytable');
					break;
				case 'add':
					xadmin.open('添加分工', '/teach/fengong/create', '650', '550');
					break;
				case 'copy': // 复制
					xadmin.open('复制分工', '/teach/fengong/copy', '650', '450');
					break;
			};
		});

		//监听行工具条
		table.on('tool(mytable)', function (obj) {
			var data = obj.data; //获得当前行数据
			var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
			var tr = obj.tr; //获得当前行 tr 的DOM对象
			switch (layEvent) {
				case 'del': // 删除
					mytable.del(obj, '/teach/fengong/delete');
					break;
				case 'edit': // 编辑
					xadmin.open('编辑分工', '/teach/fengong/edit/' + obj.data.id, '650', '450');
					break;
			};
		});

	});

</script>
{/block}